package com.dingxin.ship_together_api.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dingxin.ship_together_api.common.utils.PageUtils;
import com.dingxin.ship_together_api.common.utils.SaUtils;
import com.dingxin.ship_together_api.entity.MessageInfo;
import com.dingxin.ship_together_api.entity.vo.PageQueryVo;
import com.dingxin.ship_together_api.mapper.MessageInfoMapper;
import com.dingxin.ship_together_api.service.MessageInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* Author: ctj
* Date: 2023-01-12
* Time: 9:43
*/

@Service
public class MessageInfoServiceImpl extends ServiceImpl<MessageInfoMapper, MessageInfo> implements MessageInfoService{
    @Autowired
    private MessageInfoMapper messageInfoMapper;
    @Autowired
    private SaUtils saUtils;

    @Override public PageUtils selectPage(PageQueryVo pageQueryVo) {
        // 设置分页大小
        Page<MessageInfo> page = new Page<>(pageQueryVo.getCurrPage(),pageQueryVo.getPageSize());
        // 构造分页查询条件
        QueryWrapper<MessageInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.orderByDesc(MessageInfo.COL_CREATE_TIME);
        // 分页查询
        Page<MessageInfo> resPage = messageInfoMapper.selectPage(page, queryWrapper);
        PageUtils pageUtils = new PageUtils(resPage);
        // 结果封装
        return pageUtils;
    }
}
